package day1102.demo02;

import java.util.concurrent.*;

/**
 * @author wql
 * @version 1.0
 * @date 2022/11/2 10:36
 */

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
       //创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(2);
        //提交线程任务
        Future<Integer> submit = executorService.submit(new WqlCallable());
        //关闭线程池
        executorService.shutdown();
//         打印
        System.out.println(submit.get());

       // 这种方法代码太多不见便，我们可以直接放到线程池里，用上面的方法
//        WqlCallable wqlCallable = new WqlCallable();
//
//        FutureTask futureTask = new FutureTask(wqlCallable);
//
//        Thread thread = new Thread(futureTask);
//
//        thread.start();
//
//        System.out.println(futureTask.get());
    }
}
